using System;
using System.Collections.Generic;
using System.Text;
namespace System {
	public class Mixer {
		static void MainX() {
			string[] arr=Test("abc","1234","xyz");
			//foreach(string str in Mixer.Combine("{0}-{1}-{2}-{3}","1,2,3,4","5,6","7,8,9","a,b,c,d"))
			//  Console.WriteLine(str);
		}
		public static string[] Test(params string[] args) {
			List<string> lst=new List<string>();
			string[] arr=new string[args.Length-1];
			return lst.ToArray();

		}
		public static string[] Combine(string format,params string[] csvargs) {
			List<List<string>> pars=new List<List<string>>();
			foreach(string str in csvargs)
				pars=Mix(pars,str);
			string[] ret=new string[pars.Count];
			int cnt=0;
			foreach(List<string> par in pars)
			{
				ret[cnt++]=string.Format(format,par.ToArray());
			}
			return ret;
		}
		static List<List<string>> Mix(List<List<string>> arr1,string csv2) {
			string[] arr2=csv2.Split(',');
			if(arr1.Count==0)
			{
				List<List<string>> ret0=new List<List<string>>();
				foreach(string str in arr2)
				{
					List<string> temp=new List<string>();
					temp.Add(str);
					ret0.Add(temp);
				}
				return ret0;
			}
			List<List<string>> ret=new List<List<string>>();
			foreach(List<string> nonchg in arr1)
			{
				foreach(string extelem in arr2)
				{
					List<string> lst=new List<string>(nonchg);
					lst.Add(extelem);
					ret.Add(lst);
				}
			}
			return ret;
		}


		public static string[] CombineEx(string format,params string[] csvargs) {
			List<List<object>> pars=new List<List<object>>();
			foreach(string str in csvargs)
				pars=Mix(pars,str);
			string[] ret=new string[pars.Count];
			int cnt=0;
			foreach(List<object> par in pars)
				ret[cnt++]=string.Format(format,par.ToArray());
			return ret;
		}
		static List<List<object>> Mix(List<List<object>> arr1,string csv2) {
			string[] tarr2=csv2.Split(',');
			List<string> larr2=new List<string>();

			foreach(string str in tarr2)
				if(str.Contains("-"))
				{
					string[] rang=str.Split('-');
					if(rang.Length==2)
						for(int i=int.Parse(rang[0]);i<=int.Parse(rang[1]);i++)
							larr2.Add(i.ToString());

				}
				else
					larr2.Add(str);

			if(arr1.Count==0)
			{
				List<List<object>> ret0=new List<List<object>>();
				foreach(string str in larr2)
				{
					List<object> temp=new List<object>();
					int i;
					if(int.TryParse(str,out i))
						temp.Add(i);
					else
						temp.Add(str);
					ret0.Add(temp);
				}
				return ret0;
			}
			List<List<object>> ret=new List<List<object>>();
			foreach(List<object> nonchg in arr1)
			{
				foreach(string extelem in larr2)
				{
					List<object> lst=new List<object>(nonchg);
					int i;
					if(int.TryParse(extelem,out i))
						lst.Add(i);
					else
						lst.Add(extelem);
					ret.Add(lst);
				}
			}
			return ret;
		}
	}
}
